/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.showcase.client.page;

import com.cleangwt.bootstrap.client.style.Styles;
import com.cleangwt.bootstrap.client.ui.Dropdown;
import com.cleangwt.bootstrap.client.ui.InlineFormPanel;
import com.cleangwt.bootstrap.client.ui.Navbar;
import com.cleangwt.bootstrap.client.ui.Navigator;
import com.cleangwt.bootstrap.client.ui.Navigators;
import com.cleangwt.page.client.PageContext.CodeSplit;
import com.cleangwt.page.client.PageContext.Page;
import com.cleangwt.page.client.PageContext.Prefetch;
import com.cleangwt.showcase.client.component.ShowcasePage;
import com.cleangwt.showcase.client.resource.PageGroups;
import com.cleangwt.user.client.ui.Button;
import com.cleangwt.user.client.ui.Lay;
import com.cleangwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.FlowPanel;

/**
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
@Prefetch(PageGroups.BASE_WIDGET)
@CodeSplit
@Page
public class NavigatorDemo extends ShowcasePage {

  public NavigatorDemo() {
    super(
        "Navigator, Dropdown & Navbar",
        "Integrate bootstrap's nav styles. Refer to <a href='http://getbootstrap.com/components/#nav'>Bootstrap</a>",
        "NavigatorDemo.java");

    FlowPanel layout = new FlowPanel();
    // Base Dropdown
    Dropdown dropdown = new Dropdown("Dropdown");
    dropdown.build().addHeader("Header").addLink("Link1", "#@1").addLink("Link2", "#@A")
        .addDivider().addLink("Link3", "#@A");
    layout.add(Lay.heading("Base Dropdown"));
    layout.add(Lay.p("The dropdown menu with headers, links and dividers"));
    layout.add(dropdown);
    // Navigator
    Navigator nav1 = new Navigator();
    nav1.setStyleBase(Navigators.PILLS_STYLE);
    nav1.addLink("Link1", "#");
    nav1.addLink("Link2", "#");
    nav1.addLink("Link3", "#");
    nav1.setActive(0);
    nav1.setDisabled(2, true);

    Navigator nav2 = new Navigator();
    nav2.setStyleBase(Navigators.PILLS_STYLE);
    nav2.addStyleName(Navigators.STACKED_STYLE);
    nav2.addLink("Link1", "#");
    nav2.addLink("Link2", "#");
    nav2.addLink("Link3", "#");
    nav2.setActive(0);

    Navigator nav3 = new Navigator();
    nav3.setStyleBase(Navigators.PILLS_STYLE);
    nav3.addStyleName(Navigators.JUTIFIED_STYLE);
    nav3.addLink("Link1", "#");
    nav3.addLink("Link2", "#");
    nav3.addLink("Link3", "#");
    nav3.setActive(0);

    layout.add(Lay.heading("Navigator"));
    layout
        .add(Lay
            .p("Links with <code>hovering</code>, <code>active</code> and <code>disabled</code> styles."));
    layout.add(Lay.clazz(Styles.THUMBNAIL, nav1));
    layout.add(Lay.p("Add style <code>btn-stacked</code> to be vertically stacked."));
    layout.add(Lay.clazz(Styles.THUMBNAIL, nav2));
    layout.add(Lay.p("Add style <code>btn-justifed</code> to make links equal widths."));
    layout.add(Lay.clazz(Styles.THUMBNAIL, nav3));
    // Navbar
    Navbar navbar = new Navbar();
    Navigator navbarNav1 = new Navigator();
    Navigator navbarNav2 = new Navigator();

    layout.add(Lay.heading("Navbar"));
    layout
        .add(Lay.p("Refer to <a href='http://getbootstrap.com/components/#navbar'>Bootstrap</a>"));
    layout.add(navbar);

    navbar.setStyleBase(Navbar.DEFAULT_STYLE);
    navbar.setBrand("Brand");
    navbar.addNavigator(navbarNav1);

    navbarNav1.addLink("Link1", "#");
    navbarNav1.addLink("Link2", "#");
    navbarNav1.addDropdown("Dropdown").setDropup(true).addLink("Link3", "#").addLink("Link4", "#")
        .addLink("Link5", "#");

    InlineFormPanel form = navbar.addForm();
    form.addFormControl(new TextBox("Search"));
    form.addFormControl(new Button("Submit"));

    navbar.addNavigator(navbarNav2, true);
    navbarNav2.addLink("Link1", "#");
    navbarNav2.addDropdown("Dropdown").setDropup(true).addLink("Link2", "#").addLink("Link3", "#");

    this.setContentWidget(layout);
  }
}
